package rsj.netty.inithandler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpRequestDecoder;
import io.netty.handler.codec.http.HttpResponseEncoder;

public class NettyServerInitHandler extends ChannelInitializer<SocketChannel> {

    // 文件服务器 initChannel
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ch.pipeline().addLast("http-decoder",new HttpRequestDecoder());//httpRequest解码器
        ch.pipeline().addLast("http-aggregator", new HttpObjectAggregator(Integer.MAX_VALUE));
        ch.pipeline().addLast("http-encoder", new HttpResponseEncoder());
    }
}
